<template>
    <div>
        姓名:
        <input type="text" v-model="name">
        <button @click="onOk">ok</button>
        <div id="name">{{ myName }}</div>
    </div>
</template>

<script>
import eventBus from "../EventBus";
export default {
	data() {
		return {
            name: eventBus.person.name,
        };
	},
    computed: {
        myName() {
            return eventBus.person.name;
        }
    },
    methods: {
        onOk () {
            eventBus.$emit('changeName', this.name);
        }
    }
};
</script>

<style scoped>
</style>